<%
'IN_ConTent=CheckStr(HTMLDecode(request.form("info_content")))
Public Function GenPassword(intLen, PassMask)
    Dim iCnt, PosTemp
    Randomize
    If PassMask = "" Then
        PassMask = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"
    End If
    For iCnt = 1 To intLen
        PosTemp = Fix(Rnd(1) * (Len(PassMask))) + 1
        GenPassword = GenPassword & Mid(PassMask, PosTemp, 1)
    Next
End Function
sub GoPage(url,s)
  s=s*1000
  Response.Write "<script type='text/javascript'>"
  Response.Write "window.setTimeout("&chr(34)&"window.navigate('"&url&"')"&chr(34)&","&s&")"
  Response.Write "</script>"
end sub
Function Alert(message,gourl) 
    message = replace(message,"'","\'")
    If gourl="-1" then
        Response.Write ("<script type='text/javascript'>alert('" & message & "');history.go(-1)</script>")
    Else
        Response.Write ("<script type='text/javascript'>alert('" & message & "');location='" & gourl &"'</script>")
    End If
    Response.End()
End Function

Public Function ChkIsOuter()
		Dim server_v1,server_v2
		ChkIsOuter=True 
		server_v1=Cstr(Request.ServerVariables("HTTP_REFERER"))
		server_v2=Cstr(Request.ServerVariables("SERVER_NAME"))
		If Mid(server_v1,8,len(server_v2))=server_v2 Then ChkIsOuter=False 
End Function

Function dvHTMLEncode(fString)
if not isnull(fString) then
    fString = replace(fString, ">", "&gt;")
    fString = replace(fString, "<", "&lt;")

    fString = Replace(fString, CHR(32), "&nbsp;")
    fString = Replace(fString, CHR(9), "&nbsp;")
    fString = Replace(fString, CHR(34), "&quot;")
    fString = Replace(fString, CHR(39), "&#39;")
    fString = Replace(fString, CHR(13), "")
    fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
    fString = Replace(fString, CHR(10), "<BR> ")

    dvHTMLEncode = fString
end if
end Function
Function HTMLDecode(reString)
	Dim Str:Str=reString
	If Not IsNull(Str) Then
		Str = Replace(Str, "&amp;", "&")
		Str = Replace(Str, "&gt;", ">")
		Str = Replace(Str, "&lt;", "<")
		Str = Replace(Str, "&nbsp;", CHR(32))
	    Str = Replace(Str, "&nbsp;", CHR(9))
		Str = Replace(Str, "&#160;&#160;&#160;&#160;", CHR(9))
		Str = Replace(Str, "&quot;", CHR(34))
		Str = Replace(Str, "&#39;", CHR(39))
		Str = Replace(Str, "", CHR(13))
		Str = Replace(Str, "<br>", CHR(10))
		HTMLDecode = Str
	End If
End Function
Function HTMLEncode(reString) 
	Dim Str:Str=reString
	If Not IsNull(Str) Then
		Str = UnCheckStr(Str)
		Str = Replace(Str, "&", "&amp;")
		Str = Replace(Str, ">", "&gt;")
		Str = Replace(Str, "<", "&lt;")
		Str = Replace(Str, CHR(32), "&nbsp;")
	    Str = Replace(Str, CHR(9), "&nbsp;")
		Str = Replace(Str, CHR(9), "&#160;&#160;&#160;&#160;")
		Str = Replace(Str, CHR(34), "&quot;")
		Str = Replace(Str, CHR(39), "&#39;")
		Str = Replace(Str, CHR(13), "")
		Str = Replace(Str, CHR(10), "<br />")
		HTMLEncode = Str
	End If
End Function

Public Function GlHtml(ByVal str) 
    If IsNull(str) Or Trim(str) = "" Then
        GlHtml = ""
        Exit Function
    End If
    Dim re
    Set re = New RegExp
    re.IgnoreCase = True
    re.Global = True
    re.Pattern = "(\<.[^\<]*\>)"
    str = re.Replace(str, " ")
    re.Pattern = "(\<\/[^\<]*\>)"
    str = re.Replace(str, " ")
    Set re = Nothing
    str = Replace(str, "'", "")
    str = Replace(str, Chr(34), "")
    GlHtml = str
End Function 

Function Alert(message,gourl)
    message = replace(message,"'","\'")
    If gourl="-1" then
        Response.Write ("<script type='text/javascript'>alert('" & message & "');history.go(-1)</script>")
    Else
        Response.Write ("<script type='text/javascript'>alert('" & message & "');location='" & gourl &"'</script>")
    End If
    Response.End()
End Function

function CheckNum(str)
if isnull(str) or str=""  then
exit function
else
if not isnumeric(str) then
response.Write("<script>alert(""操作错误!"");history.back();</script>")
response.end
else
CheckNum=CLng(str)
end if
end if
end function

Function CheckStr1(byVal ChkStr) 
	Dim Str:Str=ChkStr
	Str=Trim(Str)
	If IsNull(Str) Then
		CheckStr = ""
		Exit Function 
	End If
	Dim re
	Set re=new RegExp
	re.IgnoreCase =True
	re.Global=True
	re.Pattern="(\r\n){3,}"
	Str=re.Replace(Str,"$1$1$1")
	Set re=Nothing
	Str = Replace(Str,"'","''")
	Str = Replace(Str, "!!!", "!")
	Str = Replace(Str, "★★★", "★")
	CheckStr=Str
End Function

function CheckStr(str) 
    CheckStr=replace(replace(replace(str,"<","&lt;"),">","&gt;"),chr(13),"<br />") 
   CheckStr=replace(replace(replace(replace(replace(CheckStr,"'",""),"and",""),"insert",""),"set",""),"or","") 
    CheckStr=replace(replace(replace(replace(CheckStr,"select",""),"update",""),"delete%20from",""),chr(34),"&quot;") 
end function

Function lockedIpCheck()
 dim num_ip,sql2
 	num_ip=IpEncode(ip)
    set rs=server.createobject("adodb.recordset")
	sql2="select id from FeiLockIP where int(StartIP)<="&num_ip&" and int(EndIP)>=" & num_ip
    rs.open sql2,conn
	if not rs.eof or not rs.bof then
	rs.close
	set rs=nothing
	response.write"<div style='text-align:center;'>你所在网段已被封锁。可能该网段有人捣乱，请联系管理员！</a>"
	response.end
	end if
rs.close
set rs=nothing
end function
function IpDecode(byval uip)
	if trim(uip)="" or not isnumeric(uip) then
		IpDecode=0
	else
		uip=Cdbl(uip)
		dim ary_ip(3)
        ary_ip(0)=fix(uip/16777216)
        ary_ip(1)=fix((uip-ary_ip(0)*16777216)/65536)
        ary_ip(2)=fix((uip-fix(uip/65536)*65536)/256)
        uip=uip-fix(uip/65536)*65536
        ary_ip(3)=fix(uip-fix(uip/256)*256)
        IpDecode=join(ary_ip,".")
	end if
end function

function IpEncode(byval uip)
	if isnull(uip) or uip="" then
		IpEncode=0
	else
		dim ary_ip,n
		ary_ip=split(trim(uip),".")
		n=ubound(ary_ip)
		if n=3 then
			IpEncode=ary_ip(0)*256*256*256+ary_ip(1)*65536+ary_ip(2)*256+ary_ip(3)
		else
			IpEncode=0
		end if
	end if
end function
Function IsValidEmail(email)
    Dim names, name, i, c
    IsValidEmail = True
    names = Split(email, "@")
    If UBound(names) <> 1 Then
       IsValidEmail = False
       Exit Function
    End If
    For Each name In names
        If Len(name) <= 0 Then
        IsValidEmail = False
        Exit Function
        End If
        For i = 1 To Len(name)
        c = LCase(Mid(name, i, 1))
        If InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 And Not IsNumeric(c) Then
           IsValidEmail = False
           Exit Function
         End If
       Next
       If Left(name, 1) = "." Or Right(name, 1) = "." Then
          IsValidEmail = False
          Exit Function
       End If
    Next
    If InStr(names(1), ".") <= 0 Then
        IsValidEmail = False
       Exit Function
    End If
    i = Len(names(1)) - InStrRev(names(1), ".")
    If i <> 2 And i <> 3 And i <> 4 Then
       IsValidEmail = False
       Exit Function
    End If
    If InStr(email, "..") > 0 Then
       IsValidEmail = False
    End If
End Function
Function HTMLDecode(reString)
	Dim Str:Str=reString
	If Not IsNull(Str) Then
		Str = Replace(Str, "&amp;", "&")
		Str = Replace(Str, "&gt;", ">")
		Str = Replace(Str, "&lt;", "<")
		Str = Replace(Str, "&nbsp;", CHR(32))
	    Str = Replace(Str, "&nbsp;", CHR(9))
		Str = Replace(Str, "&#160;&#160;&#160;&#160;", CHR(9))
		Str = Replace(Str, "&quot;", CHR(34))
		Str = Replace(Str, "&#39;", CHR(39))
		Str = Replace(Str, "", CHR(13))
		Str = Replace(Str, "<br />", CHR(10))
		HTMLDecode = Str
	End If
End Function
Function HTMLEncode(reString) 
	Dim Str:Str=reString
	If Not IsNull(Str) Then
		'Str = UnCheckStr(Str)
		Str = Replace(Str, "&", "&amp;")
		Str = Replace(Str, ">", "&gt;")
		Str = Replace(Str, "<", "&lt;")
		Str = Replace(Str, CHR(32), "&nbsp;")
	    Str = Replace(Str, CHR(9), "&nbsp;")
		Str = Replace(Str, CHR(9), "&#160;&#160;&#160;&#160;")
		Str = Replace(Str, CHR(34), "&quot;")
		Str = Replace(Str, CHR(39), "&#39;")
		Str = Replace(Str, CHR(13), "")
		Str = Replace(Str, CHR(10), "<br />")
		HTMLEncode = Str
	End If
End Function
%>